package edu.tongji.jiaowu.dao.jdbc;

import java.util.List;

import edu.tongji.jiaowu.dao.TeacherDao;
import com.tongji.quickCRUDQ.define.Row;
import com.tongji.quickCRUDQ.model.CommonBean;
import com.tongji.quickCRUDQ.dao.jdbc.BaseDaoJdbc;

public class TeacherDaoJdbc extends BaseDaoJdbc implements TeacherDao {
	String tableName = "T_TEACHER";

	String beanName = "teacher";

	public CommonBean createTeacher() {
		CommonBean teachers = this.createBean(tableName, beanName);
		return teachers;
	}

	/*
	 public CommonBean findTeachers(String refid) {
	 CommonBean teachers=this.createTeacher();
	 String sql="select * from T_TEACHER where refid=?";
	 List data=this.getCommonDao().select(sql,new String[]{refid});
	 teachers.addData(data);
	 return teachers;
	 }
	 */
	public CommonBean findTeacherById(String id) {
		CommonBean teachers = this.createTeacher();
		String sql = "select * from T_TEACHER where id=?";
		List data = this.getCommonDao().select(sql, new String[] { id });
		teachers.addData(data);
		return teachers;
	}

	public CommonBean findAllTeachers() {
		CommonBean teachers = this.createTeacher();
		String sql = "select * from T_TEACHER ";
		List data = this.getCommonDao().select(sql, new String[] {});
		teachers.addData(data);
		return teachers;
	}

	public void insertTeacher(CommonBean teacherBean) {
		List data = teacherBean.getData();
		Row row = this.getRow(tableName);
		this.getCommonDao().templateBatchInsert(row, data, this.getIdGenerator());
	}
}
